- /* slfpfprd.cpp by K.Tsuru */
- // function ID 2012 DRADIX since ver 2.182
- // first version made on 24 Apr 2010
- /***********************************************************
- make product
- p[0]^a*p[1]^b*p[2]^c...
- ***********************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SLong PrimeFactorProduct(const SNBlock <primeFactor>& pf, int n) {
- SNBlock <SLong> w(4);
- int wc = 0, pc = 0;
- int pow = pf(0).power;
- SNBlock <SLong> wSL(n);
-
- while(pc < n) {
- // bind factors with the same power
- // ...(a^p)(b^p)(c^p)... --> ...(abc)^p...
- int k = 0;
- for(; pow == pf(pc).power; pc++) { // while the same power
- w.reserve(k);
- w[k].SetInt( pf(pc).prime );
- k++;
- }
- if(k > 1) { // k : number of the same power
- wSL[wc] = BothSideProduct(w, k, false); // sort is not necessary
- } else wSL[wc] = w[0]; // only one element
- if(pow > 1) wSL[wc] = Lpow( wSL[wc], (ulong)pow ); // wSL[wc]^pow
- wc++;
- pow = pf(pc).power; // next power
- }
- SLong Q = TournamentProduct(wSL, wc);
- return Q;
- }
slfpfprd.cpp : last modifiled at 2015/06/02 15:50:24(1,067 bytes)
created at 2017/10/07 10:26:50
The creation time of this html file is 2017/11/09 14:52:03 (Thu Nov 09 14:52:03 2017).